#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

#include <iostream>
#include <vector>
using namespace std;

vector<vector<int>> sol(int n, int m) {
    vector<vector<vector<int>>> dp(m + 1);
    for (int i = 1; i <= min(n, m); ++i) {
        dp[i].push_back({ i });
        for (int j = m; j > i; --j) {
            int sz = dp[j - i].size();
            for (int k = 0; k < sz; ++k) {
                if (j - i != i) {
                    dp[j].push_back(dp[j - i][k]);
                    dp[j].back().push_back(i);
                }
            }
        }
    }
    return dp[m];
}

int main() {

    vector<vector<int>> ret = sol(5, 5);
    for (auto& v : ret) {
        for (auto x : v)
            cout << x << " ";
        cout << endl;
    }
}
